
export function flattenArray (array) { // 拉平数组————good
  let newArr = []
  for (let i = 0; i < array.length; i++) {
    if (Array.isArray(array[i])) { // 当前项为数组
      newArr.push.apply(newArr, flattenArray(array[i])) // TODO:apply
    } else {
      newArr.push(array[i])
    }
  }
  return newArr
}

export function checkObj (obj1, obj2) { // 检验对象是否相同
  return JSON.stringify(obj1) === JSON.stringify(obj2)
}

export function removeDuplicate (obj) { // 对象去重
  return Array.from(new Set(obj))
}

export function checkType (obj) { // 检查类型
  let type = ''
  switch (Object.prototype.toString.call(obj)) {
    case '[object Object]':
      type = 'Object'
      break
    case '[object Array]':
      type = 'Array'
      break
    case '[object Function]':
      type = 'Function'
      break
    case '[object String]':
      type = 'String'
      break
    case '[object Number]':
      type = 'Number'
      break
    case '[object Boolean]':
      type = 'Boolean'
      break
    case '[object Undefined]':
      type = 'Undefined'
      break
    case '[object Null]':
      type = 'Null'
      break
  }
  return type
}
